# -*- coding: utf-8 -*-
# @Time    : 2021/5/13 0013 21:19
# @Author  : 蒋才果
# @Email   : 1476235300@qq.com
# @File    : 游戏.py
# @Software: PyCharm
import random
class Role:

     def __init__(self, name, sex):
         self.name = name
         self.sex = sex
         # 装备
         self.equip = None
         self.blood = 100

     #攻击
     def attack(self):
         print("%s[%s]发动攻击哒哒..." % (self.name,self.blood//5*"+"))

     #受击
     def shouji(self):
         a = random.randint(0,3)
         if a == 1:
             print("%smiss发出嘿嘿的声音剩余%d血量" %(self.name,self.blood))
             return

         if self.equip is None:
             self.blood -= 10
             print("%s发出呃呃的声音剩余%d血量" %(self.name, self.blood))
             print()
             if self.blood <= 0:
                 print("%s 败" % self.name)
                 exit()

         else:
             self.blood -= 5
             print("%s发出呃呃的声音剩余%d血量" % (self.name, self.blood))
             if self.blood <= 0:
                 print("%s 败" % self.name)
                 exit()


class House:
    # 回合
    bout = 1

    def __init__(self):
        self.lst = []

    def __str__(self):
        return "游戏开始啦".center(50,"=")

    def join(self,name):
        self.lst.append(name)

    def Vs(self):
        while 1:
            print(f"第{House.bout}回合".center(50,"="))
            self.lst[0].attack()
            self.lst[1].shouji()
            self.lst[1].attack()
            self.lst[0].shouji()
            House.bout += 1


house = input("创建房间号")
print("房间创建成功快去加入格斗吧".center(50,"="))
house = House()

while True:
    name = input("输入你的名字")
    sex = input("输入你的性别")
    user = Role(name,sex)
    num = input("输入1为你加上防弹衣")
    if num == '1':
        user.equip = '防弹衣'
    house.join(user)
    if len(house.lst) == 2:
        print(house)
        house.Vs()




